﻿--DomainScope-----------------
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DomainScope]'))
DROP TABLE [dbo].[DomainScope]
GO

CREATE TABLE [dbo].[DomainScope](
	[Key] [uniqueidentifier] NOT NULL DEFAULT NEWID(),
	[Name] [nvarchar](50) NOT NULL,
	[Code] [varchar](20) NOT NULL,
	[Type] [int] NOT NULL DEFAULT 0, --IS IM OR CONTENT
	[Description] [nvarchar](200) NULL,
 CONSTRAINT [PK_DomainScope] PRIMARY KEY CLUSTERED 
([Key] ASC)ON [PRIMARY])

GO

--DomainScopeUser-----------------
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DomainScopeUser]') AND type in (N'U'))
DROP TABLE [dbo].[DomainScopeUser]
GO
CREATE TABLE [dbo].[DomainScopeUser](
	[Key] [uniqueidentifier] NOT NULL DEFAULT NEWID(),
	[PersonKey] [uniqueidentifier] NULL,
	[DomainScopeKey] [uniqueidentifier] NOT NULL,
	[ThirdPartyIdentity] [nvarchar](200) NOT NULL,
	[ThirdPartyDisplay] [nvarchar](200) NULL,
	[Description] [nvarchar](MAX) NULL,
	[MonitorStatus] [bit] NOT NULL DEFAULT 0,
	[CreatedStamp] [datetime] NOT NULL,
	[LastUpdatedStamp] [datetime] NOT NULL,
 CONSTRAINT [PK_DomainScopeUser] PRIMARY KEY CLUSTERED 
([Key] ASC) ON [PRIMARY])
GO
